import request from '@/untils/request'
import type { codeState, backLogin, UseringoResponseData } from '@/api/email/type'
import type { wxType } from '@/api/email/type'

interface loginType {
  phone: string
  code: string
}

enum API {
  GET_CODE = '/sms/send/',
  // 登录
  LOGIN_CODE = '/user/login',
  // 微信
  GET_INFO_WX = '/user/weixin/getLoginParam/',
  // 获取用户实名认证信息
  GET_REAL_INFO = '/user/auth/getUserInfo'
}

export const getCode = (phone: string) => request.get<any, codeState>(API.GET_CODE + phone)

export const loginCode = (data: loginType) => request.post<any, backLogin>(API.LOGIN_CODE, data)

export const getInfoWx = (wxRedirectUri: string) =>
    request.get<any, wxType>(API.GET_INFO_WX + `?wxRedirectUri=${wxRedirectUri}`)
export const getRealInfo = () => request.get<any, UseringoResponseData>(API.GET_REAL_INFO)